<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'product-form',
	'enableAjaxValidation'=>false,
  'htmlOptions'=>array('enctype' => 'multipart/form-data')
)); ?>

<p class="note">
<?php echo Yii::t('default', 'field_with', array('{star}'=>'<span class="required">*</span>'))?>
</p>

<?php echo $form->errorSummary($model, '', '', array('class' => 'alert alert-error')); ?>

<div class="tabs-container">
  <ul class="tabs-frame">
    <li>
      <a href="#"> 
        <img src="<?php echo Yii::app()->baseUrl?>/images/language/vietnam-icon.png" alt="vn">
      </a>
    </li>
    <li>
      <a href="#">
        <img src="<?php echo Yii::app()->baseUrl?>/images/language/uk-icon.png" alt="uk">
      </a>
    </li>
  </ul>
  <div class="tabs-frame-content">
    <div class="column one-half">
      <label>
        <?php echo Yii::t('default', 'Product', array(), null, 'vi')?> <span class="required">*</span> 
      </label>
        <?php echo $form->textField($model, 'name')?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Description', array(), null, 'vi')?>
      </label>
        <?php echo $form->textArea($model, 'description', array('row'=>3))?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Detail', array(), null, 'vi')?>
      </label>
        <?php
        $this->widget('ext.ckeditor.CKEditorWidget',array(
            "model"=>$model,
            "attribute"=>'detail',
            "config" => array(
              "language"=>"vi",
              "height"=>"300px",
        ),
        ));
        ?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Price', array(), null, 'vi')?> 
      </label>
      <?php echo $form->textField($model, 'price')?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Color', array(), null, 'vi')?> 
      </label>
      <?php //echo $form->dropdownList($model,'color',Color::model()->getColorList(),array('prompt'=>Yii::t('default', 'Select a color')))?>
      <?php echo $form->textField($model, 'color')?>
    </div>
  </div>
  <div class="tabs-frame-content">
    <div class="column one-half">
      <label>
        <?php echo Yii::t('default', 'Product', array(), null, 'en')?> <span class="required">*</span> 
      </label>
        <?php echo $form->textField($model, 'name2')?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Description', array(), null, 'en')?> <span class="required">*</span> 
      </label>
        <?php echo $form->textArea($model, 'description2')?>
    </div>
    
    <div class="column one-column">
      <label><?php echo Yii::t('default', 'Detail', array(), null, 'en')?>
        <span class="required">*</span> </label>
        <?php
        $this->widget('ext.ckeditor.CKEditorWidget',array(
            "model"=>$model,
            "attribute"=>'detail2',
            "config" => array(
              "language"=>"en",
              "height"=>"300px",
        ),
        ));
        ?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Price', array(), null, 'en')?> 
      </label>
      <?php echo $form->textField($model, 'price2')?>
    </div>
    
    <div class="column one-column">
      <label>
        <?php echo Yii::t('default', 'Color', array(), null, 'en')?> 
      </label>
      <?php //echo $form->dropdownList($model,'color',Color::model()->getColorList(),array('prompt'=>Yii::t('default', 'Select a color')))?>
      <?php echo $form->textField($model, 'color2')?>
    </div>
  </div>
</div>

<div class="column one-column">
<?php echo $form->labelEx($model,'categoryID'); ?>
<?php echo $form->dropdownList($model,'categoryID', Category::model()->getCategories(), array('prompt' => Yii::t('default', 'Select a category')))?>
</div>

<div class="column one-column">
<?php echo $form->labelEx($model, Yii::t('default', 'Images')); ?>
<?php
  $this->widget('CMultiFileUpload', array(
  	'model'=>$model,
    'name' => 'Product[image]',
    'accept'=>'jpeg|jpg|gif|png',
    'denied'=>yii::t('default', 'Accept files').': jpg, jpeg, gif, png.',
    'max'=>-1,
    'duplicate'=>Yii::t('default', 'Duplicated file!'),
    'remove'=>'<i class="icon-remove"></i> ',
    'options'=>array( 
    )
  ));
?>
<?php if(!$model->isNewRecord && !empty($image)) {?>
<div class="clearfix">
<?php foreach ($image as $item) { ?>
  <div class="MultiFile-label" id="file_<?php echo $item['id']?>">
  <a href="javascript: void(0)" onclick="DeleteImage('<?php echo $item['id']?>')"><i class="icon-remove"></i></a>
  <?php echo CHtml::link($item['name'], Yii::app()->baseUrl . '/upload/product/post-images/' . $item['save'], array('target' => '_blank')); ?>
  </div>
<?php } ?>
</div>
<?php }?>
<p class="note" ><?php echo yii::t('default', 'Accept files')?>: jpg, jpeg, gif, png.</p>
</div>

<div class="column one-column">
<?php echo $form->labelEx($model,'size'); ?>
<?php //echo $form->dropdownList($model,'sizeID',Size::model()->getSizeList(),array('prompt'=>Yii::t('default', 'Select a size')))?>
<?php echo $form->textField($model, 'size')?>
</div>

<div class="clear">
<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('default', 'Create') : Yii::t('default', 'Update')); ?>
</div>

<?php $this->endWidget(); ?>
<script type="text/javascript">
function DeleteImage(id) {
  var notice = '<?php echo Yii::t('default', 'delete_confirm', array('{this_item}'=>Yii::t('default', 'this file')));?>';
  if(confirm(notice)) {
    $.ajax({
        type: "GET",
        url: baseUrl + '/admin/product/deleteimage',
        data: {id: id},
        success: function(result){
          if (result == 'success') {
            $("#file_"+id).remove();
          }
       }
      });
  }
}
</script>